#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>


using namespace std;

typedef struct ListNode
{
	int val;
	struct ListNode* next;
}Node;

Node* BuyNode(int val)
{
    Node* newnode = new Node;
    newnode->next = NULL;
    newnode->val = val;
    return newnode;
}

Node* CreatList(int n)
{
    Node* head = BuyNode(1);
    Node* tail = head;
    for (int i = 2;i <= n;i++)
    {
        Node* newnode = BuyNode(i);
        tail->next = newnode;
        tail = tail->next;
    }
    tail->next = head;
    return tail;
}

void ysf(int n, int m,vector<int>& v) {
    Node* prev = CreatList(n);
    Node* cur = prev->next;
    int count = 1;
    while (cur != cur->next)
    {
        if (count == m)
        {
            v.push_back(cur->val);
            count = 1;
            prev->next = cur->next;
            delete cur;
            cur = prev->next;
        }
        else {
            count++;
            prev = cur;
            cur = cur->next;
        }
    }
    v.push_back(cur->val);
}

int main()
{
    int n, m;
    vector<int> v;
    v.reserve(3010);

    cin >> n >> m;
    ysf(n, m, v);

    for (auto e : v)
    {
        cout << e << " ";
    }
    cout << endl;

	return 0;
}